/*
 * Board.fx
 *
 * Created on 2009-09-04, 11:39:55
 */

package shmallarchitect.gui;

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;


/**
 * @author Administrator
 */

public class Board extends CustomNode {
    public var gridWidth: Number;
    public var gridHeight: Number;

    public var verticalSpaces: Number = 20;
    public var horizontalSpaces: Number = 20;

    // The actual board pieces
    public var squares : BoardSquare[];

    // The boards content
    var content : Group = Group{};
    var iteration: Integer = 0;



    public function EditSquare (l :Integer, locid: Integer) :Void {
       var temp = bind squares[l];
       temp.localid = locid;
       temp.selected = false;
       temp.bgcolor = BaseLayout.local_list[locid].getLocumcolor();
    }

    public function get_localid(l :Integer): Integer {
            
       var temp = bind squares[l];
       return temp.localid;
    }

    override function create():Node {

        for (x in [0..(horizontalSpaces - 1)]) {
            for (y in [0..(verticalSpaces - 1)]) {
                    insert BoardSquare
                    {
                        squareID: iteration;
                        pieceHeight: bind gridHeight / verticalSpaces;
                        pieceWidth: bind gridWidth / horizontalSpaces;
                        positionX: x.intValue();
                        positionY: y.intValue();
                        board: this
                    } into squares;

                    iteration++;
            }
        }



        insert squares into content.content;

        return content;
    }
}
